<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="x" uri="http://www.yf1706.com/yf1706/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<link type="text/css" rel="stylesheet" href="../zxy/css/emp_info/emp_basic.css">
	<div class="zxy_eb_content">
		<div class="zxy_eb_view_content">
			<table class="zxy_eb_table">
				<tbody>
					<tr>
						<td><span class="zxy_eb_table_title">编号</span></td>
						<td><span class="zxy_eb_table_item">${pcr.recordId }</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">员工编号</span></td>
						<td><span class="zxy_eb_table_item">${pcr.empId }</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">员工姓名</span></td>
						<td><span class="zxy_eb_table_item">${pcr.empName }</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">部门</span></td>
						<td><span class="zxy_eb_table_item">${pcr.dep }</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">职务</span></td>
						<td><span class="zxy_eb_table_item">${pcr.post}</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">申请者编号</span></td>
						<td><span class="zxy_eb_table_item">${pcr.applyEmpId}</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">申请者姓名</span></td>
						<td><span class="zxy_eb_table_item">${pcr.applyEmpName}</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">申请日期</span></td>
						<td><span class="zxy_eb_table_item">${pcr.applyDate}</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">审批状态</span></td>
						<td><span class="zxy_eb_table_item">
							<c:choose>  
							    <c:when test="${pcr.approveStatus==1}">  
							    	待审批  
							    </c:when>  
							    <c:when test="${pcr.approveStatus==2}">  
							    	审批通过  
							    </c:when>  
							    <c:when test="${pcr.approveStatus==3}">  
							    	待修改 
							    </c:when>  
							    <c:when test="${pcr.approveStatus==4}">  
							    	取消 
							    </c:when> 
							    <c:otherwise>  
							    	取消 
							    </c:otherwise> 
							</c:choose>  
						</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">审批者编号</span></td>
						<td><span class="zxy_eb_table_item">${pcr.approverId}</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">审批者姓名</span></td>
						<td><span class="zxy_eb_table_item">${pcr.approver}</span></td>
					</tr>	
					<tr>
						<td><span class="zxy_eb_table_title">审批部门</span></td>
						<td><span class="zxy_eb_table_item">${pcr.approveDep}</span></td>
					</tr>	
					<tr>
						<td><span class="zxy_eb_table_title">审批日期</span></td>
						<td><span class="zxy_eb_table_item">${pcr.approveDate}</span></td>
					</tr>	
					<tr>
						<td><span class="zxy_eb_table_title">变动日期</span></td>
						<td><span class="zxy_eb_table_item">${pcr.changeDate}</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">文件号</span></td>
						<td><span class="zxy_eb_table_item">${pcr.docNum}</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">备注</span></td>
						<td><span class="zxy_eb_table_item">${pcr.remark}</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">审批意见</span></td>
						<td><span class="zxy_eb_table_item">${pcr.approveComments}</span></td>
					</tr>	
				</tbody>
			</table>
		</div>
	</div>
	
	<div class="zxy_eb_content">
		<div class="zxy_eb_view_content">
			<table class="zxy_eb_table">
				<tbody>
					<tr>
						<td><span class="zxy_eb_table_title">原部门</span></td>
						<td><span class="zxy_eb_table_item">${pcr.originalDep }</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">新部门</span></td>
						<td><span class="zxy_eb_table_item">${pcr.newDep }</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">原职称</span></td>
						<td><span class="zxy_eb_table_item">${pcr.originalPost}</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">新职称</span></td>
						<td><span class="zxy_eb_table_item">${pcr.newPost}</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">原职级</span></td>
						<td><span class="zxy_eb_table_item">${pcr.originalRank}</span></td>
					</tr>
					<tr>
						<td><span class="zxy_eb_table_title">新职级</span></td>
						<td><span class="zxy_eb_table_item">${pcr.newRank}</span></td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
	<div style="padding:40px;width:100%;float:left">
		<a class="easyui-linkbutton" onClick="azy_pcri_back()">返回</a>
		<c:if test="${pcr.approveStatus==1}">
			<x:g id="17">
				<a class="easyui-linkbutton" onClick="azy_pcri_approve(${pcr.recordId})">审批通过</a>
			</x:g>
		</c:if>
		<c:if test="${pcr.approveStatus==1||pcr.approveStatus==3}">
			<x:g id="15">
				<a class="easyui-linkbutton" onClick="azy_pcri_edit(${pcr.recordId})">修改</a>
			</x:g>
		</c:if>
		<c:if test="${pcr.approveStatus==1}">
			<x:g id="17">
				<a class="easyui-linkbutton" onClick="azy_pcri_reject(${pcr.recordId})">退回修改</a>
			</x:g>
		</c:if>
		<c:if test="${pcr.approveStatus==1||pcr.approveStatus==3}">
			<x:g id="16">
				<a class="easyui-linkbutton" onClick="azy_pcri_cancel(${pcr.recordId})">取消</a>
			</x:g>
		</c:if>
	</div>
	
	<!-- 编辑的窗口 -->
	<div id="zxy_pcri_dl" class="easyui-dialog">
		<form id="zxy_pcri_dl_form" class="easyui-form" method="post">
			<div class="zxy_eb_content">
				<div>
					<table class="zxy_eb_table">
						<tbody>
							<tr>
								<td><span class="zxy_eb_table_title">原部门</span></td>
								<td><span class="zxy_eb_table_item">${pcr.originalDep }</span></td>
							</tr>
							<tr>
								<td><span class="zxy_eb_table_title">新部门</span></td>
								<td><input class="zxy_ebe_table_item easyui-combobox" 
										id="zxy_pcri_dep" data-options="editable:false"></td>
							</tr>
							<tr>
								<td><span class="zxy_eb_table_title">原职称</span></td>
								<td><span class="zxy_eb_table_item">${pcr.originalPost}</span></td>
							</tr>
							<tr>
								<td><span class="zxy_eb_table_title">新职称</span></td>
								<td><input class="zxy_ebe_table_item easyui-combobox" 
										id="zxy_pcri_post" data-options="editable:false"></td>
							</tr>
							<tr>
								<td><span class="zxy_eb_table_title">原职级</span></td>
								<td><span class="zxy_eb_table_item">${pcr.originalRank}</span></td>
							</tr>
							<tr>
								<td><span class="zxy_eb_table_title">新职级</span></td>
								<td><input class="zxy_ebe_table_item easyui-combobox" 
										id="zxy_pcri_rank" data-options="editable:false"></td>
							</tr>
							<tr>
								<td><span class="zxy_eb_table_title">批准人</span></td>
								<td><input class="zxy_ebe_table_item easyui-combobox" 
										id="zxy_pcri_approver"></td>
							</tr>
							<tr>
								<td><span class="zxy_eb_table_title">批准部门</span></td>
								<td><input class="zxy_ebe_table_item easyui-textbox" 
										id="zxy_pcri_approver_dep"></td>
							</tr>	
							<tr>
								<td><span class="zxy_eb_table_title">文件号</span></td>
								<td><input class="zxy_ebe_table_item easyui-textbox" 
										id="zxy_pcri_doc_num"></td>
							</tr>
							<tr>
								<td><span class="zxy_eb_table_title">备注</span></td>
								<td><input class="zxy_ebe_table_item easyui-textbox" 
										id="zxy_pcri_remark"></td>
							</tr>
						</tbody>
					</table>
				</div>
			</div>
		</form>
	</div>
	
	<script>
		var zxy_pcri_approveComments='${pcr.approveComments}';
		var zxy_pcri_record_id='${pcr.recordId}';
		function azy_pcri_reject(recordId){
			$.messager.prompt('Prompt', '输入审批意见', function(r){
				if(r){
					$.ajax({
						url:'../personnelChange/rejectPositionChangeRecord',
						data:{
							recordId:zxy_pcri_record_id,
							approveComments:r
						},
						success:function(data){
							if(data){
								$.messager.alert('操作成功',data.message);
							}else{
								$.messager.alert('操作失败',data.message);
							}
						}
					});
					$("#tt").tabs('getTab','员工职位变动').panel('open').panel('refresh','../personnelChange/positionChangeRecordList');
				}
			});
		}
		function azy_pcri_approve(recordId){
			$.messager.prompt('Prompt', '输入审批意见', function(r){
				if(r){
					$.ajax({
						url:'../personnelChange/approvePositionChangeRecord',
						data:{
							recordId:zxy_pcri_record_id,
							approveComments:r
						},
						success:function(data){
							if(data){
								$.messager.alert('操作成功',data.message);
							}else{
								$.messager.alert('操作失败',data.message);
							}
						}
					});
					$("#tt").tabs('getTab','员工职位变动').panel('open').panel('refresh','../personnelChange/positionChangeRecordList');
				}
			});
		}
		
		$("#zxy_pcri_dep").combobox({
			url:'../dep/findAllDep',
			valueField:'depId',
			textField:'depName'
		});
		$("#zxy_pcri_post").combobox({
			url:'../setting/findAllPostSetting',
			valueField:'postId',
			textField:'postName'
		});
		$("#zxy_pcri_rank").combobox({
			url:'../setting/findAllRankSetting',
			valueField:'rankId',
			textField:'rankName'
		});
		$("#zxy_pcri_approver").combobox({
			url:'../user/findAllUserBasic',
			valueField:'userId',
			textField:'userName',
			onSelect:function(record){
				console.log("record");
				console.log(record.depId);
				$("#zxy_pcri_approver_dep").textbox('setText',record.depName);
			},
		});
		$("#zxy_pcri_approver_dep").textbox({
			valueField:'depId',
			textField:'depName',
			disabled:true
		});
		
		$("#zxy_pcri_doc_num").textbox({
		});
		$("#zxy_pcri_remark").textbox({
		});
		
		$("#zxy_pcri_dl").dialog({
			width:500,
			height:400,
			collapsible:false,
			minimizable:false,
			maximizable:false,
			resizable:false,
			closed:true,
			buttons: [{
				text:'保存',
				iconCls:'icon-ok',
				handler:function(){
					var newDep=$("#zxy_pcri_dep").textbox('getValue');
					var newPost=$("#zxy_pcri_post").combobox('getValue');
					var newRank=$("#zxy_pcri_rank").combobox('getValue');
					if(newPost==''&&newDep==''&&newRank==''){
						$.messager.alert('错误','变动内容为空');
						return;
					}
					var approver=$("#zxy_pcri_approver").combobox('getValue');
					var approverDep=$("#zxy_pcri_approver_dep").textbox('getText');
					if(approver==''){
						$.messager.alert('错误','必须选择审批者');
						return;
					}
					var docNum=$("#zxy_pcri_doc_num").textbox('getText');
					var remark=$("#zxy_pcri_remark").textbox('getText');
					console.log(newDep+"-"+newPost+"-"+newRank+"-"+approver+"-"+approverDep+"-"+docNum+"-"+remark);
					$.ajax({
						url:'../personnelChange/editPositionChange',
						type:'post',
						data:{
							recordId:zxy_pcri_record_id,
							newDep:newDep,
							newPost:newPost,
							newRank:newRank,
							approver:approver,
							approverDep:approverDep,
							docNum:docNum,
							remark:remark
						},
						success:function(data){
							if(data.success){
								$.messager.alert('操作成功',data.message);
								$("#tt").tabs('getTab','员工职位变动').panel('open').panel('refresh','../personnelChange/positionChangeRecordList');
							}else{
								$.messager.alert('操作失败',data.message);
							}
						},
					});
					$("#zxy_pcri_dl").window('close');
				}
			},{
				text:'取消',
				iconCls:'icon-cancel',
				handler:function(){
					$("#zxy_pcri_dl_form").form('clear');
					$("#zxy_pcri_dl").window('close');
				}
			}]
		});
		function azy_pcri_edit(recordId){
			$("#zxy_pcri_dl").window('open');
		}
		function azy_pcri_back(){
			$("#tt").tabs('getTab','员工职位变动').panel('open').panel('refresh','../personnelChange/positionChangeRecordList');
		}
		function azy_pcri_cancel(recordId){
			$.messager.confirm("操作提示", "您确定要取消吗？", function (data) {
				if(data) {
					$.ajax({
						url:'../personnelChange/cancelPersitionChange',
						data:{
							recordId:recordId
						},
						success:function(data){
							if(data.success){
								$.messager.alert('操作成功',data.message);
								$("#tt").tabs('getTab','员工职位变动').panel('open').panel('refresh','../personnelChange/positionChangeRecordList');
							}else{
								$.messager.alert('操作失败',data.message);
							}
						}
					});
				}
			});
			
		}
	</script>
</body>
</html>